package com.its.controller;

import com.its.domain.BaseResult;
import com.its.domain.CodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public BaseResult bizExceptionHandler(HttpServletRequest req, Exception e){
        log.error("请求异常",e);
        return BaseResult.error(CodeEnum.SYSTEM_ERROR);
    }
}
